package com.lingyuan.warehouse.controller;

import com.lingyuan.common.core.domain.R;
import com.lingyuan.common.core.domain.vo.call.WareCall;
import com.lingyuan.common.core.domain.vo.wms.WmsWareSkuVO;
import com.lingyuan.warehouse.domain.WareSkuVO;
import com.lingyuan.warehouse.domain.WmsWareSkuPO;
import com.lingyuan.warehouse.service.SkuWareService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName SkuWareController
 * @Description 描述
 * @Author guoxin
 * @Date 2024/9/24 19:26
 */
@RestController
@RequestMapping("/skuWare")
public class SkuWareController {
    @Autowired
    private SkuWareService skuWareService;
    /**
     * 添加商品库存
     */
    @PostMapping("/addSkuWare")
    public R addSkuWare(@RequestBody WmsWareSkuVO wmsWareSkuVO){
        WareSkuVO wareSkuVO = new WareSkuVO();
        BeanUtils.copyProperties(wmsWareSkuVO,wareSkuVO);
        skuWareService.addSkuWare(wareSkuVO);
        return R.ok("添加成功");
    }
    /**
     * 锁定库存
     */
    @PostMapping("/lockStock")
    public R lockStock(@RequestBody List<WareCall> wareCallList){
        skuWareService.lockStock(wareCallList);
        return R.ok();
    }
    /**
     * 释放库存
     */
    @PostMapping("/releaseStock")
    public R releaseStock(@RequestBody List<WareCall> wareCallList){
        skuWareService.releaseStock(wareCallList);
        return R.ok();
    }
}
